<template>
	<view>
		<TopHead :title="'评价列表'"></TopHead>
		<view class="conbox">
			<comment-list :commentList="commentList"></comment-list>
		</view>
	</view>
</template>

<script>
	import TopHead from '../../components/topHead/topHead.vue';
	import CommentList from '../../components/basics/commentList.vue';
	export default {
		components: {
			TopHead,
			CommentList
		},
		data() {
			return {
				path: this.$http.tpUrl + '/', // 图片前缀
				list: [{
					name: '郑毅',
					headImage: 'https://ceres.zkthink.com/static/img/user/morentouxiang.png',
					score: 4,
					comment: '这是一个好问题，但是你不配得到答案，这是一个好问题，但是你不配得到答案...',
					images: ['https://ceres.zkthink.com/static/img/user/morentouxiang.png',
						'https://ceres.zkthink.com/static/img/user/morentouxiang.png'
					],
					createTime: '202403-19 16:30',

				}],
				commentList: [], // 
				page: 1,
				pageSize: 20, // 
				total: 0, // 总数
				ProductEntityId:'', // 商品id

			}
		},
		onLoad(options) {
			console.log(options)
			this.ProductEntityId = options.ProductEntityId||''
			
		},
		onShow() {
			this.page = 1
			this.total = 0
			this.commentList = []
			this.evaluateData()
			// this.initData()
		},
		onReachBottom() {
			// 触底分页
			console.log('触底')
			if (this.total > this.commentList.length) {
				this.page = parseInt(this.page) + 1
				this.$nextTick(() => {
					this.evaluateData()
				})
			}
		},
		methods: {
			// 获取评论
			evaluateData() {
				let _this = this;
				let data = {
					page: _this.page,
					pageSize: _this.pageSize,
					userId: uni.getStorageSync('id'),
					productEntityId: _this.ProductEntityId
				}
				_this.$http.fetchData({
					url: '/wechatApplet/customer/evaluate/',
					method: 'GET',
					data: data,
					success(res) {
						// uni.showToast({
						// 	title: res.message,
						// 	icon: 'none'
						// });
						let commentList = res.data.list
						commentList.forEach((item) => {
						  console.log(item);
						  for (let i = 0; i < item.photoList.length; i++) {
						  	item.photoList[i]= _this.path+item.photoList[i]
						  }
						})
						_this.commentList = [..._this.commentList, ...commentList]
						_this.total = res.data.total
						console.log(_this.commentList)

					}
				})
			},

			// dianhua
			phoneCall(item) {
				uni.makePhoneCall({
					phoneNumber: '023-62433333' //仅为示例
				});
			},


		}
	}
</script>

<style scoped>
	.headBox {
		font-size: 36rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Bold;
		font-weight: 700;
		text-align: center;
		color: #232323;
		padding-top: 88rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		padding-bottom: 112rpx;
		background: linear-gradient(89deg, #f9d7a6 1%, #ffdc95 100%);
	}

	.headBox .wzText {
		line-height: 56rpx;
	}

	.conbox {
		padding: 30rpx;
		padding-top: 240rpx;
	}

	.title1 {
		font-size: 28rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Bold;
		font-weight: 700;
		color: #5d4529;
		padding-bottom: 50rpx;
		border-bottom: 2rpx solid rgba(94, 94, 94, 0.1);
	}

	.title1 text {
		font-size: 28rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Regular;
		font-weight: 400;
		color: #5d4529;
		margin-left: 94rpx;

	}

	.title2 {
		font-size: 28rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Bold;
		font-weight: 700;
		border-bottom: 2rpx solid rgba(94, 94, 94, 0.1);
		padding: 50rpx 0;
		color: #5d4529;
		position: relative;
	}

	.title2 button {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		opacity: 0;
		z-index: 2;
	}

	.title2 .right {
		position: absolute;
		right: 0;
		top: 50%;
		margin-top: -20rpx;
	}
</style>